package day1008_3;

import day0922.EmployeeDao;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class EmployeeDaoImpl  implements EmployeeDao {
    Collection<String>  collection=new ArrayList();

    public void insertEmployee(String name) {//调用集合的add
        collection.add(name);
    }


    public void showAll() {//调用集合collection的迭代器
        Iterator<String> ite=collection.iterator();//集合方法获取迭代器对象
        while(ite.hasNext()){//B.用迭代器的hasNext()
            String str=ite.next();//C.用迭代器的 方法从集合中获取一个元素
            System.out.print(str+",");
        }
        System.out.println( );
    }

    public boolean isExists(String name) {//调用集合的contains
        boolean rs=collection.contains(name);
        return rs;
    }


    //实现接口需要： 实现接口中的所有的抽象方法
}








